/**
 * 开发时间：2016/5/24
 * 开发人员：boxUnll
 * 开发项目：移动端滑动验证代码
 */
    var oBtn = document.getElementById('btn');
    var oW,oLeft;
    var oSlider=document.getElementById('slider');
    var oTrack=document.getElementById('track');
    var oIcon=document.getElementById('icon');
    var oSpinner=document.getElementById('spinner');
    var oBtnR=document.getElementById('button_right');



    oBtn.addEventListener('touchstart',function(e){

        var touches = e.touches[0];

        oW = touches.clientX - oBtn.offsetLeft;    //触摸目标的X坐标
        oBtn.className="button";
        oTrack.className="track";
        // document.addEventListener("touchmove",defaultEvent,false);//阻止页面的滑动默认事件
    },false);

    oBtn.addEventListener("touchmove",move,false);


    oBtn.addEventListener("touchend",function() {
        if(oLeft>=(oSlider.clientWidth-oBtn.clientWidth)){
            oBtn.style.left = (document.documentElement.clientWidth - oBtn.offsetWidth-80);
            oTrack.style.width= (document.documentElement.clientWidth - oBtn.offsetWidth-80);
             oBtnR.style.display='none';
            // oSpinner.style.display='block';
            // oSpinner.setAttribute("class","icon-ok icon-3x");
            document.getElementById("wordFirst").innerHTML="";
            document.getElementById('successTest').innerHTML="&nbsp;&nbsp;&nbsp;验证成功！";
            document.getElementById('successTest').style.color='#ffffff';
            // document.removeEventListener("touchmove",move,false);//阻止页面的滑动默认事件




            oBtn.removeEventListener("touchmove",move,false);//阻止页面的滑动默认事件


        }else{
            oBtn.style.left = 0;
            oTrack.style.width= 0;
        }

        oTrack.className="track-on";
        oBtn.className="button-on";
       


    },false);

    function defaultEvent(e) {
        e.preventDefault();
    }
    function  move(e){
        var touches = e.touches[0];
        oLeft = touches.clientX - oW;    //滑块滑动的真实距离

        if(oLeft < 0) {
            oLeft = 0;
        }else if(oLeft-1 > document.documentElement.clientWidth - oBtn.offsetWidth-80) {  //大于滑动验证块的距离
            oLeft = (document.documentElement.clientWidth - oBtn.offsetWidth-80);
        }


        oBtn.style.left = oLeft + "px";
        oTrack.style.width=oLeft+ 'px';
    }
